package com.huluobo.a2206koltindouyin.home

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.bean.NewsBean
import com.huluobo.base.bean.NewsTypeBean
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
 *  Created by LC on 2024/11/4.
 */
@HiltViewModel
class HomeViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val getNewsTypeSuccess by lazy { MutableLiveData<List<NewsTypeBean>>() }
    fun getNewsType() {
        executeNetRequest(
            { apiService.getNewsType() },
            getNewsTypeSuccess::postValue
        )
    }

    val getNewsListSuccess by lazy { MutableLiveData<List<NewsBean>>() }
    fun getNewsList(currentPage: Int, pageSize: Int, newsTypeId: Int) {
        executeNetRequest(
            { apiService.getNewsList(currentPage, pageSize, newsTypeId) },
            getNewsListSuccess::postValue
        )
    }

}